package com.shuiyun.jtt.enums;

import lombok.Getter;

/**
 * @author shuiyun
 * @program gateway
 * @description 多媒体类型
 * @date 2022-05-07 22:30
 **/
public enum MultimediaType {

    // 多媒体格式编码
    JPEG(0,".jpeg"),
    TIF(1,".tif"),
    MP3(2,".mp3"),
    WAV(3,".wav"),
    wmv(4,".wmv");

    @Getter
    private final Integer code;

    @Getter
    private final String postfix;

    MultimediaType(Integer code, String postfix) {
        this.code = code;
        this.postfix = postfix;
    }

    /**
     * 根据多媒体编码获取文件后缀
     * @param code 文件编码
     * @author shuiyun
     * @date 2022/5/7 22:35
     * @return 文件后缀
     */
    public static String getPostfix(Integer code){
        for (MultimediaType value : values()) {
            if (value.getCode().equals(code)){
                return value.getPostfix();
            }
        }
        return null;
    }
}
